Allow parsing strings larger than 2GiB#147
Merged
kou merged 1 commit intoruby:masterfrom Apr 13, 2025
Merged
Conversation
kou
reviewed
Apr 10, 2025
kou
reviewed
Apr 10, 2025
kou
reviewed
Apr 10, 2025
test/strscan/test_stringscanner.rb
Outdated
| def test_large_string | ||
| six_gib = (6 * 1024 * 1024 * 1024) | ||
| string = "a" * six_gib | ||
| s = create_string_scanner(string) # 6 GiB string |
Member
There was a problem hiding this comment.
Does this mean that we need at least 6 GiB memory to run this test...?
Contributor
Author
There was a problem hiding this comment.
Indeed. I don't know how to test it otherwise. I could reduce the size to a bit more than 4GiB, or even 2GiB given it's signed.
We could also just not test it, but this revealed that the Java version has the same limitation, so I think it was valuable. (I won't update the JRuby version though, because there everything uses an int so it's way to much work for me. cc @headius)
Contributor
Author
There was a problem hiding this comment.
I ended up removing the test, as it also doesn't work on windows, nor on 32bit systems.
e54d2f7 to
e6b8698
Compare
ad278f2 to
58505f7
Compare
For a reason unknown, even though `pos` is stored as a `long`, the `#pos` and `#pos=` treat it as an `int`, which prevent skeeing into strings larger than 2GiB.
matzbot
pushed a commit
to ruby/ruby
that referenced
this pull request
Apr 14, 2025
(ruby/strscan#147) For a reason unknown, even though `pos` is stored as a `long`, the `#pos` and `#pos=` treat it as an `int`, which prevent seeking into strings larger than 2GiB. ruby/strscan@b76368416e Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For a reason unknown, even though
posis stored as along, the#posand#pos=treat it as anint, which prevent seeking into strings larger than 2GiB.cc @kou